{include file="public/head" /}
<title>{$pri_name}</title>
{in name="$Request.action" value="index,index2,house,get_son,my_son,my_parent"}

{include file="public/index_css" /}
{/in}

{in name="$Request.action" value="family,create,update,batch_create,mysql,copy,replace,room,update_car,year_order,recharge"}
{include file="public/create_css" /}
{/in}
<link rel="stylesheet" href="__CONSOLE__/treetable/css/jquery.treetable.css" />
<link rel="stylesheet" href="__CONSOLE__/treetable/css/jquery.treetable.theme.default.css" />

<link rel="stylesheet" href="__CONSOLE__/wow/css/animate.css">

<script src="__CONSOLE__/wow/js/wow.js"></script>
<script>

    var wow = new WOW({
        boxClass: 'wow',
        animateClass: 'animated',
        offset: 0,
        mobile: true,
        live: true
    });
    wow.init();

</script>
<script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
</head>
<body class="nav-md" id="index_returnTop">
<div class="container body">
    <div class="main_container">
        {include file="public/left" /}
        <!-- top navigation -->
        {include file="public/top" /}
        <!-- /top navigation -->

        <!-- page content -->
        <div class="right_col" role="main">
            {include file="public/search" /}

            <div class="clearfix"></div>

            <div class="row">
                <!-- table content-->
                {__CONTENT__}
                <!-- table content-->
            </div>
        </div>
    </div>
    <!-- /page content -->
    <!-- footer content -->
    {include file="public/foot" /}
    <!-- /footer content -->
</div>
</div>

{in name="$Request.action" value="index,index2,room,house,get_son,my_son,my_parent"}
{include file="public/index_js" /}
{/in}
{in name="$Request.action" value="family,create,update,batch_create,mysql,copy,replace,update_car,year_order,recharge"}
{include file="public/create_js" /}
{/in}
<style>
    .xj_img{
        display: block;
        margin: 0 auto;
    }
    .zz{
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.3);
        position: fixed;
        left: 0;
        right: 0;
        top:0;
        display: none;
        z-index: 9999;
    }
    .zz img{
        width: 800px;
       // height: 800px;
        position: absolute;
        top:50%;
        left: 50%;
        margin-top: -400px;
        margin-left: -400px;
    }
</style>
<div class="zz">
    <img src="" alt="">
</div>
</body>
</html>
<script>
    $(".xj_img").click(function () {
        $(".zz").show();
        var src = $(this).attr('src');
        $(".zz img").attr("src",src);
    });
    $(".zz").click(function () {
        $(this).hide()
    })
</script>
<script src="__CONSOLE__/treetable/jquery.treetable.js"></script>
<script>
    $("#example-basic").treetable({ expandable: true });

    $("#example-basic-static").treetable();

    $("#example-basic-expandable").treetable({ expandable: true });

    $("#example-advanced").treetable({ expandable: true });

    // Highlight selected row
    $("#example-advanced tbody").on("mousedown", "tr", function() {
        $(".selected").not(this).removeClass("selected");
        $(this).toggleClass("selected");
    });

    // Drag & Drop Example Code要不控制台报错
    // $("#example-advanced .file, #example-advanced .folder").draggable({
    //     helper: "clone",
    //     opacity: .75,
    //     refreshPositions: true, // Performance?
    //     revert: "invalid",
    //     revertDuration: 300,
    //     scroll: true
    // });

    $("#example-advanced .folder").each(function() {
        $(this).parents("#example-advanced tr").droppable({
            accept: ".file, .folder",
            drop: function(e, ui) {
                var droppedEl = ui.draggable.parents("tr");
                $("#example-advanced").treetable("move", droppedEl.data("ttId"), $(this).data("ttId"));
            },
            hoverClass: "accept",
            over: function(e, ui) {
                var droppedEl = ui.draggable.parents("tr");
                if(this != droppedEl[0] && !$(this).is(".expanded")) {
                    $("#example-advanced").treetable("expandNode", $(this).data("ttId"));
                }
            }
        });
    });

    $("form#reveal").submit(function() {
        var nodeId = $("#revealNodeId").val()

        try {
            $("#example-advanced").treetable("reveal", nodeId);
        }
        catch(error) {
            alert(error.message);
        }

        return false;
    });
</script>
<!--selected-->
<script src="__PLUGIN__/select2/dist/js/select2.js"></script>
<script src="__PLUGIN__/select2/dist/js/select2.full.js"></script>

<script>
    $('.bottom').attr('colspan',$('thead th').length);//底部colspan水平对齐
    $('[type="submit"]').click(function () {
        //如果验证不通过，按钮就不显示了
        //$(this).hide();
    });
    $(document).ready(function () {
        // select2
        $(".single_select").select2({
            placeholder: "请选择",
            allowClear: true
        });

        var aaaa="";
        $(".multi_select").select2({
            placeholder: '请选择',

            language: "zh-CN",
            allowClear:true,
            closeOnSelect:false,
            maximumSelectionLength: 10,  //最多能够选择的个数,
            //
            // nextSearchTerm: function(selectedObject, currentSearchTerm) {
            //     //下一次点击select2下拉时上一次的搜索内容还在，下拉显示的是根据搜索内容出现的结果
            //     return aaaa;
            // },
            // tokenizer: function(e) {
            //     //每输入一个值，更新一次变量
            //     aaaa = e;
            // }


        });

    });
</script>
<!--<link rel="stylesheet" href="__PLUGIN__/layui/css/layui.css"  >-->
<script src="__PLUGIN__/auto-grow-input/jquery.auto-grow-input.js"></script>

<!--<script src="__PLUGIN__/layui/layui.js"></script>-->
<!--和layerdate冲突 否则create里的create_time失效-->
<!--首页修改单一字段-->
<script type="text/javascript">

    $(function () {

        $('table tbody td[field]').click(function () {
            if ($("tbody td:not(':first')")) {
                if (!$(this).is('.input')) {

                    $(this).addClass('input').html('<del style="display: none;">'+$(this).text()+'</del><input type="text" style="border:none;display: inline;" value="' + $(this).text() + '" />').find('input').focus().blur(function () {

                        //console.log(111111111111111111111);
                        var thisid = $(this).parent().siblings("tbody td:eq(0)").text();
                        var thisvalue = $(this).val();
                        var thisclass = $(this).parent().attr("field");
                        $.ajax({
                            type: 'POST',
                            url: "{:url('setField')}",
                            data: "id=" + thisid + "&field=" + thisclass + "&value=" + thisvalue,

                            success: function (data) {
                                console.log(data);
                                if (data.code == 200) {
                                    layer.msg(data.message);
                                } else {
//layer.msg(data.message);
                                }
                            },
//请求失败，包含具体的错误信息
                            error: function (e) {
//                                      console.log(e.status);
//                                      console.log(e.responseText);
                            }
                        });
                       // $(this).parent().removeClass('input').html($(this).val() || 0);
                    });
                }
                $(function(){
                    $('table').find('input').autoGrowInput();//自动宽度了 那就不需要在设置了
                });
                $(window).resize(function(){ $('#demo-input').trigger('autogrow'); });

                // $(this).find('input').keyup(function(){
                //    // $("input").css("background-color","#D6D6FF");使用不了
                // });
                // var p = $(this).find('del').width();
                //
                //  $(this).find('input').width(p);
                // console.log(p);
            }



            // var textWidth = function (text) {
            //     console.log(text);
            //     var sensor = $('<pre>' + text + '</pre>').css({ display: 'none' });
            //     $('body').append(sensor);
            //     var width = sensor.width();
            //     sensor.remove();
            //     return width;
            // };
            //
            // $("input").unbind('keydown').bind('keydown', function () {
            //     $(this).width(textWidth(l) * 1.2);
            //
            // });
        }).hover(function () {
            //console.log(123);
            $(this).addClass('hover');
        }, function () {
            //console.log(12111);
            $(this).removeClass('hover');
        });

    });

</script>
<script type="text/javascript" src="__CONSOLE__/datepicker/daterangepicker.js"></script>
<script src="__PLUGIN__/laydate/laydate.js"></script>
<script>
    // laydate.render({
    //     elem: '.year'
    //     ,type: 'datetime'
    // });
    //http://layui-doc.pearadmin.com/doc/modules/laydate.html 不好使手册
    // layui.use('laydate', function(){
    //     var laydate = layui.laydate;
    //     //执行一个laydate实例
    //     laydate.render({
    //         elem: '.year' //指定元素
    //         ,type: 'datetime'
    //     });
    // });
</script>


<script>
    $('#colspan').attr('colspan',50);
    function imgExists(e){
    console.log(e.src);
        //默认图片
        var imgUrl = "https://account.acgxt.com/public/images/default.png";
        var img = new Image();
        img.src=imgUrl;
        //判断图片大小是否大于0 或者 图片高度与宽度都大于0
        if(img.filesize>0||(img.width>0&&img.height>0)){
            e.src = imgUrl;
        }else{
            //默认图片也不存在的时候
             e.src = imgUrl;
        }
    }
</script>
<link rel="stylesheet" href="__PLUGIN__/layui-master/dist/css/layui.css">

<!-- 引入 layui.js -->
<script src="__PLUGIN__/layui-master/dist/layui.js"></script>
<!--<script>-->
<!--    document.onkeydown = function (e) { // 回车提交表单-->
<!--// 兼容FF和IE和Opera-->
<!--        var theEvent = window.event || e;-->
<!--        var code = theEvent.keyCode || theEvent.which || theEvent.charCode;-->
<!--        if (code == 13) {-->
<!--            $('#search').submit();-->
<!--        }-->
<!--    }-->
<!--</script>-->
<!--boostrap 自定义按钮-->
<style>
    .btn-cyan{
        color: #fff;
        background-color: #00b7ee;
        border-color: #2e6da4;
        display: inline-block;
        padding: 6px 12px;
        margin-bottom: 0;
        font-size: 14px;
        font-weight: 400;
        line-height: 1.42857143;
        text-align: center;
        white-space: nowrap;
        text-decoration: none;
        vertical-align: middle;
        -ms-touch-action: manipulation;
        touch-action: manipulation;
        cursor: pointer;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        background-image: none;
        border: 1px solid transparent;
        border-radius: 4px;
    }
    button.btn:hover{
        background-color: #00a2d4;color: #fff;
    }
</style>

<script>

    //2 3级分类切换
    $('[name="cat_id"]').change(function () {
        var cat_id = $(this).val();
        $.ajax({
            type: 'POST',
            url: "{:url('get_son_list')}",
            data: {parent_id: cat_id},
            success: function (ret) {
                console.log(ret);
                $('[name="cat_id2"]').html('');
                $('[name="cat_id3"]').html('');
                var str = '<option value=""> --请选择分类-- </option>';
                $.each(ret.data,function (k,v) {
                    str += '<option value="'+v['id']+'">'+v['title']+'</option>';
                })
                $('[name="cat_id2"]').html(str);
            }
        });
    });
    $('[name="cat_id2"]').change(function () {
        var cat_id = $(this).val();
        $.ajax({
            type: 'POST',
            url: "{:url('get_son_list')}",
            data: {parent_id: cat_id},
            success: function (ret) {
                console.log(ret);
                $('[name="cat_id3"]').html('');
                var str = '<option value=""> --请选择分类-- </option>';
                $.each(ret.data,function (k,v) {
                    str += '<option value="'+v['id']+'">'+v['title']+'</option>';
                })
                $('[name="cat_id3"]').html(str);
            }
        });
    });

    function GetRegion(val,level){
        var $city = $("#city");
        var $area = $("#area");

        $.ajax({
            type: "post",
            url: "{:url('console/common/getRegion')}",
            data: { pcode: val,level:level},
            beforeSend: function(){
                if(level=='1'){
                    $city.html('<option value=""> --请选择市-- </option>');
                    $city.val('');
                }
                $area.html('<option value=""> --请选择区-- </option>');
                $area.val('');
            },
            success: function(data) {
                var dataObj=eval("("+data+")");//转换为json对象
                if(dataObj['code']==1){
                    if(level=='1'){
                        $.each(dataObj['list'], function(i, item) {
                            $city.append('<option value="'+item['value']+'">'+item['name']+'</option>');
                        });
                    }else{
                        $.each(dataObj['list'], function(i, item) {
                            $area.append('<option value="'+item['value']+'">'+item['name']+'</option>');
                        });
                    }
                }
            },
            error: function(err){
                console.log(JSON.stringify(err));
            }
        });
    }

</script>